package com.webdev.newtech.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.webdev.newtech.domain.TlService;
import com.webdev.newtech.service.ITlServiceService;
import com.webdev.newtech.utils.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("tlservice")
public class TlServiceController {
    @Resource
    ITlServiceService serviceService;
    @GetMapping("list")
    public AjaxResult list(Integer pageNum, Integer pageSize, TlService service){
        System.out.println("获取列表");
        PageHelper.startPage(pageNum,pageSize);
        List<TlService> list = serviceService.getList(service);
        PageInfo info = new PageInfo<TlService>(list);
        return AjaxResult.success(info);
    }
    @GetMapping("add")
    public AjaxResult add(TlService service){
        System.out.println("新增");
        return AjaxResult.success(serviceService.add(service));
    }
    @GetMapping("update")
    public AjaxResult update(TlService service){
        System.out.println("更新");
        return AjaxResult.success(serviceService.update(service));
    }
    @GetMapping("remove")
    public AjaxResult list(Integer id){
        System.out.println("根据id删除");
        return AjaxResult.success(serviceService.remove(id));
    }
}
